fn for_dot_dot_default() {
    for n in 1..101 {
        if n % 15 == 0 {
            println!("fizzbuzz");
        } else if n % 3 == 0 {
            println!("fizz");
        } else if n % 5 == 0 {
            println!("buzz");
        } else {
            println!("{}", n);
        }
    }
}

fn for_dot_dot_both_inclusive() {
    for n in 1..=100 {
        if n % 15 == 0 {
            println!("fizzbuzz");
        } else if n % 3 == 0 {
            println!("fizz");
        } else if n % 5 == 0 {
            println!("buzz");
        } else {
            println!("{}", n);
        }
    }
}

fn iterate_using_iter() {
    let names = vec!["Bob", "Frank", "Ferris",];
    for name in names.iter() {
        match name {
            &"Ferris" => println!("There is a rustacean among us!"),
            _ => println!("Hello {}", name),
        }
    }
    println!("names: {:?}", names);
}

fn iterate_using_into_iter() {
    let names = vec!["Bob", "Frank", "Ferris",];
    for name in names.into_iter() {
        match name {
            // different from iter, here cannot add &, because here name isnot a refference
            "Ferris" => println!("There is a rustacean among us!"),
            _ => println!("Hello {}", name),
        }
    }
    // println!("names: {:?}", names);
    // FIXME ^ Comment out this line
}


fn iterate_using_iter_mut() {
    let mut names = vec!["Bob", "Frank", "Ferris",];
    for name in names.iter_mut() {
        *name = match name {
            &mut "Ferris" => {println!("There is a rustacean among us!"); *name},
            _ => "Hello",
        }
    }
    println!("names: {:?}", names);
}

fn main() {
    for_dot_dot_default();
    println!();
    println!();
    println!();
    for_dot_dot_both_inclusive();
    println!();
    println!();
    println!();
    iterate_using_iter();
    println!();
    println!();
    println!();
    iterate_using_into_iter();
    println!();
    println!();
    println!();
    iterate_using_iter_mut();
}